//当日养护
var vm = new Vue({
	el: '#app',
	data: function() {
		return {
			p: 0,
			pageSize: 20,
			menu1: {
				"chosedId": [],
				"chosedName": "",
				"list": [{
					"id": "1",
					"name": "已完成",
					"chosed": false
				}, {
					"id": "2",
					"name": "进行中",
					"chosed": false
				}, {
					"id": "3",
					"name": "待执行",
					"chosed": false
				}]
			},
			menu2: {
				"chosedId": [],
				"chosedName": "",
				"list": [{
					"id": "1",
					"name": "土建",
					"chosed": false
				}, {
					"id": "2",
					"name": "机电",
					"chosed": false
				}, {
					"id": "3",
					"name": "保洁",
					"chosed": false
				}, {
					"id": "4",
					"name": "道路",
					"chosed": false
				}, {
					"id": "5",
					"name": "绿化",
					"chosed": false
				}, {
					"id": "6",
					"name": "排水",
					"chosed": false
				}, {
					"id": "7",
					"name": "其他",
					"chosed": false
				}]
			},
			menu3: {
				"chosedId": [],
				"chosedName": "",
				"list": [{
					"id": "1",
					"name": "长期作业",
					"chosed": false
				}, {
					"id": "2",
					"name": "短期作业",
					"chosed": false
				}, {
					"id": "3",
					"name": "临时作业",
					"chosed": false
				}]
			},
			dataList: []
		}
	},
	mounted: function() {
		var that = this;
		mui.init({
		});
		mui('.mui-scroll-wrapper').scroll({
			deceleration: 0.0005 //flick 减速系数，系数越大，滚动速度越慢，滚动距离越小，默认值0.0006
		});
		that.getData();
		mui.ready(function() {
			$('#listBox').on('tap', '.icon-dianhua', function() {
				var tel = $(this).data('tel');
				window.location.href = 'tel:' + tel;
			})
		})
	},
	methods: {
		getData: function(loadtype) {
			loading.show();
			var that = this;
			that.p++;
			$.getJSON('/define/getPlanToday', {
				"page": that.p, //页码
				"perpage": that.pageSize, //每页条目
				"complete_status": that.menu1.chosedName, //
				"projecttype": that.menu2.chosedName, //
				"roadclosure": that.menu3.chosedName //
			}, function(res) {
				console.log(that.p)
				that.dataList = res;
				loading.hide();
			})
		},
		pulldownRefresh: function() {
			var that = this;
			that.getData();
		},
		pullupRefresh: function() {
			var that = this;
			that.getData();
		},
		stateChangeMenu: function(menu) {
			var that = this;
			that.menu1.chosedId = menu.id;
			that.menu1.chosedName = menu.name;
		},
		zyChangMenu: function(menu) {
			var that = this;
			that.menu2.chosedId = menu.id;
			that.menu2.chosedName = menu.name;
		},
		fdChangeMenu: function(menu) {
			var that = this;
			that.menu3.chosedId = menu.id;
			that.menu3.chosedName = menu.name;
		},
		//跳转页码
		goPage: function() {
			var that = this;
			that.getData();
		}

	},
	filters: {
		timeFormat: function(val) {
			if(!val) return;
			var time = val.substring(5, 20);
			time = time.replace('/', '-');
			return time;
		}
	}
})